import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', {
  state: () => ({
    userInfo: {}
  }),
  getters: {},
  actions: {
    // 更新用户信息
    updateUserInfo(newValue) {
      this.userInfo = newValue
    },
    // 退出后，清空用户信息，并清除localStorage
    clearUserInfo() {
      localStorage.removeItem("isLogin");
      localStorage.removeItem("userInfo");
      this.userInfo = {}
    }
  }
})

export default useUserStore